stage.set_background_color("black")
sprite = codesters.Point(50, 100)
sprite.pen_down()
sprite.set_color("red")
# Allow the user to move the point right, left, up, down
def left_key():
sprite.move_left(20)
stage.event_key("left", left_key)
def right_key():
sprite.move_right(20)
stage.event_key("right", right_key)
def down_key():
sprite.move_down(20)
stage.event_key("down", down_key)
def up_key():
sprite.move_up(20)
stage.event_key("up", up_key)
# Allow the user to change the color of the pen randomly
colors = ["green", "red", "yellow", "orange", "pink", "lightblue"]
def space_bar():
pen_color = random.choice(colors)
sprite.set_color(pen_color)
sprite.set_say_color("white")
sprite.say("Space bar!", 0.2)
stage.event_key("space", space_bar)
# Allow the user to change the width of the pen randomly
def w_key():
pass # delete after adding indented code
width = int(sprite.ask("Enter a number for the width!"))
sprite.pen_width(width)
sprite.set_say_color("white")
sprite.say("New Width!", 0.2)
# add other actions...
stage.event_key("w", w_key)
tester = TestManager()
tester.display_success_message("Great job!")
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)